home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / popt.arc / P-OPT.DOC next >
Text File  |  1987-04-29  |  18KB  |  410 lines

  1.  
  2.                                  P - OPT
  3.                                  v. 1.0
  4.                        " Power Tools for Power Users "
  5.  
  6.                                By Gizmo Mike
  7.                             (C) InfoSoft, 1987
  8.                      The Information booth (316) 684 8744
  9.  
  10.      1.0   Introduction
  11.  
  12.       P - OPT is a PROCOMM command file optimizer and a whole lot more!
  13.     What it will do for you is read a PROCOMM command file and optimize it
  14.     for speed at runtime.  As procomm executes a command file, it reads every
  15.     single byte much as an interpeter would.  While using the 4 letter
  16.     abbreviations would speed up execution, it makes lengthy source code
  17.     harder to read and modify.
  18.  
  19.       P-OPT will allow you to comment liberally in the original command file,
  20.     then optimize it for speed.  This leaves you with 2 "versions" one with
  21.     comments and such for future modifications, and another streamlined for
  22.     fast, Fast, FAST, FASTEST execution at runtime.
  23.  
  24.       Basically, when run, P-OPT will read the specified command file, then
  25.     optimize it by removing any lines that are totally remarks, strip remarks
  26.     from other lines, strip trailing and leading spaces (ie it undoes
  27.     indentation) then substitutes the short for for the commmand key word
  28.     (MESSAGE becomes MESS, TRANSMIT becomes TRANS etc).
  29.  
  30.  
  31.      1.1  Execution Time
  32.  
  33.       Granted, this is not for your average 5 line command file, but for
  34.     larger intricate command files, it can help out a bunch.   VERSA, a
  35.     PC Pursuit navigator, in its commented form is 915 lines, 36K.  Once run
  36.     thru P-OPT, is shrinks to a lean and mean 658 lines, 10.7K.  And it is
  37.     fast!  On an AT the process takes 23 secs, on a PC a mere 72 secs!
  38.  
  39.  
  40.      1.2   Basic P-OPT functions
  41.  
  42.        Functions supported in P-OPT, mainly thru the use of meta commands:
  43.  
  44.     * Optimize PROCOMM scripts for optimimum run time.
  45.       - Remove leading space from quoted strings.
  46.       - Substitute 4 character form of all, most or some PROCOMM command
  47.         words.
  48.       - Truncate labels to the first 8 characters and a ":".
  49.       - Truncate label references (GOTO LONGLABEL) to first 8 characters.
  50.       - Remove blank lines from source.
  51.       - Strip trailing spaces and remarks from source.
  52.     * Produce printed output directly from P-OPT
  53.     * Allow for remarks of special significance to remain in the optimized
  54.         output.
  55.     * Assign text strings via meta-commands to title and label the output.
  56.     * Produce a crossreference, of optimized code, with a SOURCE line
  57.       number.
  58.  
  59.  
  60.      2.0   Command line syntax
  61.  
  62.        A few parameters are passed to P-OPT from the command line.  P-OPT's
  63.     command line arguments ARE POSITIONAL!
  64.  
  65.     Syntax:  P-OPT  source[.CMD] target[.OPT] [/c | /nc ]
  66.  
  67.  
  68.      2.1   Command line parameters
  69.  
  70.        The first parameter passed tells P-OPT what source file to optimize.
  71.     You can enter the extension of .CMD or not, but P-OPT will look for
  72.     source.CMD.  If it does not exist it will tell you.
  73.  
  74.       The second parameter is the output file name.  Here, you can enter
  75.     the extension of .OPT or not, but P-OPT will output to target.OPT.  If
  76.     the file exists, P-OPY will ask you if you are sure that you want to
  77.     overwrite it.  If you do not, if will prompt you for a new filename.
  78.     If you wish to output to a printer, then use LPT1 or LPT2 (whichever is
  79.     appropriate) as the output filename.
  80.  
  81.        The final parameter allows for color (/C) or blah non color (/NC)
  82.     screen display at runtime.
  83.  
  84.  
  85.      3.0   Meta Command Intro
  86.  
  87.       Additionally, P-OPT offers a set of meta-commands.  Meta-commands, if
  88.     you are not familar with them, are intructions to an intermediate program
  89.     as opposed to the final program.  Here a meta-command is a way of sending
  90.     an instruction to P-OPT (as opposed to PROCOMM) in the script file.
  91.  
  92.       In this case, the meta-commands allow you to send instructions to P-OPT
  93.     as it is optimizing your source file.  Other meta-commands allow you to
  94.     preserve certain strings that might otherwise be stipped from the source
  95.     file.
  96.  
  97.  
  98.      3.1 Meta-Command syntax
  99.  
  100.       P-OPT metacommands all begin with a PROCOMM remark character (";") and
  101.     end with a colon ":" and are 8 characters.  The ";" prevents the meta
  102.     commands from interfering with PROCOMM, and the rest makes it easy for
  103.     P-OPT to recognize the line as a meta-command
  104.  
  105.     The metacommands currently supported are:
  106.  
  107.     ;$TITLE:       -   The title or name of your script file
  108.     ;$SUBTL:       -   A date or whatever tickles your fancy
  109.     ;$AUTHR:       -   List the author of the script file
  110.     ;$VERSN:       -   A version number if you wish
  111.  
  112.     ;$REMRK:       -   A remark to remain in target file
  113.  
  114.     :$PGSIZ:       -   Number of lines to print per page
  115.     ;$PAGEF:       -   If output is to LPTx, send unconditional Form Feed
  116.     ;$LNCNT:       -   Yes/No (1/0) switch for line numbers
  117.  
  118.  
  119.  
  120.     3.2  Meta-Command usage
  121.  
  122.       Basically, P-OPT will not strip meta-commands from the source file,
  123.     unless told to.  This allows you to place your name, a subtitle, a
  124.     version etc in a script file and not have P-OPT strip it from the source
  125.     file.  A meta-command MUST begin in column 1 of the source file or it too
  126.     is stripped from the source and may as well have been a simple PROCOMM
  127.     remark.
  128.       Additionally, the ;$REMRK: meta-command will not be stripped even if
  129.     the ;$MCMDS: switch is off.  This makes it additioanlly helpful when used
  130.     right.
  131.  
  132.       Right:
  133.     +----------------------------
  134.     |;$REMRK:  Be careful not to change S6 !!
  135.     |ASSIGN S6="foo-bar"
  136.  
  137.      Wrong:
  138.     +--------------------------------------
  139.     |ASSIGN S6="foo-bar"         ;$REMRK:  Be careful not to change S6 !!
  140.  
  141.       Additionally, the ;$REMRK: meta-command will not be stripped even if
  142.     the ;$MCMDS: switch is off.  This makes it additioanlly helpful when used
  143.     right.
  144.  
  145.  
  146.     3.3   Printing with Meta-Commands
  147.  
  148.       If you are outputting to a printer via P-OPT, the last 4 meta-commands
  149.     allow additional printer control: the first two control page length
  150.     and compressed or normal type.  If you have an intricate routine or
  151.     subroutine going, you can force a formfeed at a specific point that makes
  152.     sence to you with ;$PAGEF:.  In so doing, the line counter internal to
  153.     P-OPT will reset to 0.  This means that the next formfeed will be
  154.     however many lines later that you have $PGSIZ: set to.
  155.  
  156.  
  157.       Finally, P-OPT will place the author, title, subtitle and version meta-
  158.     command assignment at the top of each page, as well as a page number.
  159.     For this reason, if you attempt to make multiple $SUBTL: assignments,
  160.     only the last one would be printed. Eg:
  161.  
  162.      Command file:                        Printed output:
  163.     ;$TITLE: My command file              My Command File
  164.     ;$AUTHR: Gizmo Mike                   Gizmo Mike
  165.     ;$VERSN: Version 1.01                 Version: 1.01
  166.     ;$SUBTL: A fine program               I wrote today
  167.     ;$SUBTL: I wrote today
  168.  
  169.  
  170.      This is not a glitch but a compromise made for speed, but adds an
  171.     additional benefit explained later.
  172.  
  173.  
  174.  
  175.     3.3.5  Printer meta-command placement
  176.  
  177.        The 3 printer meta-commands, if used, should be placed in the very
  178.     beginning of the source file after $AUTHR:, $TITLE:, $VERSN: and $SUBTL;
  179.     If none of the printer meta-commands appear in the first fifteen lines
  180.     of the source, the defaults are used and suprious results may occur.
  181.     Printer meta-commands are ignored and stripped when outputting to disk.
  182.  
  183.  
  184.     3.4   Disk File output
  185.  
  186.       Of cource you will not always output to a printer.  If output is to a
  187.     disk file, the printer related meta-commands are ignored, but they still
  188.     remain in the target file.  However, the others will come in handy.
  189.     In the top portion of the source you can put a copyright notice, a
  190.     version etc and they will 'survive' P-OPT to remain in the target file.
  191.     As with the print mode, only the last meta-command assignment is
  192.     retained.
  193.  
  194.     If you are outputting to a disk file, you may find the $REMRK very handy.
  195.     It simply marks a line as a "super-remark" that will survive the P-OPT
  196.     process to also appear in the target file.
  197.  
  198.  
  199.     3.6   Meta - Command Caution
  200.  
  201.       Meta-commands are a very powerful feature of P-OPT, and should be used
  202.     with discretion.  Using too many $REMRK 's will make the output file
  203.     larger and wordier than necessary, defeating the purpose of P-OPT.
  204.       In fact the only meta-cpmmand that should be used more than once is
  205.     $REMRK:, $SUBTL: and possibly $PAGEF: if you are outputting to printer.
  206.     The others should be assigned once.
  207.  
  208.  
  209.      4.0  Outputting a source/output cross reference
  210.  
  211.         Whether you are outputting to the printer or a disk file, you can
  212.     tell P-OPT to produce a cross reference of your script command file by
  213.     setting $LNCNT: to a positive number in the source.
  214.  
  215.     When cross referencing, a fully optimized file is output with the
  216.     addition of line numbers.  The SOURCE line, NOT target line.  This means
  217.     that numbers will NOT be sequential, since simple remarks and blank
  218.     lines are removed.  But this allows you to reference the target
  219.     file against a commented source file at run time.
  220.  
  221.     While, this is fully optimized, the commented line numbers will slow it
  222.     down, but as a debugging aid in large script files, this should be very
  223.     useful.
  224.  
  225.     Sample cross reference output:
  226.  
  227.     GOTO PRGM_END                               ;Src Line #:  69
  228.     ENDC                                        ;Src Line #:  70
  229.     ENDS                                        ;Src Line #:  71
  230.     BEGIN:                                      ;Src Line #:  85
  231.     SET CR_I CR                                 ;Src Line #:  86
  232.     SET PARI EVEN                               ;Src Line #:  87
  233.  
  234.  
  235.  
  236.     Though not tested, in theory, later in the file, you could toggle off
  237.     the line numbers with a "$LNCNT:0" meta-command.
  238.  
  239.  
  240.       5.0   External Data file
  241.  
  242.        All that P-OPT needs to know to run is read from the command line, but
  243.     in the interest of flexibility, it reads the translation for long to
  244.     short form of PROCOMM command words from an external file called (and
  245.     hard coded as such) PROCMDS.LST.  This is created with a standard ASCII
  246.     text editor in the format of:
  247.                  LONGNAME,LNAM
  248.     with the long, formal name on the left, the abbreviated form on the
  249.     right, separated by a comma.  Note that the PROCMDS.LST you should have
  250.     recieved with P-OPT.EXE may or may not be a complete list of PROCOMM
  251.     command words!  Look thru it compared to the PROCOMM docs and edit as you
  252.     need.
  253.  
  254.     DO NOT ADD ANY COMMANDS THAT ARE UNDER 5 CHARACTERS LONG!  Adding
  255.     words like RGET and SEND or FIND to the list is pointless, first because
  256.     they do not have a shorter abbreviation, second P-OPT ignores anything
  257.     under 4 characters long, third adding them just for the sake of adding
  258.     them will cause P-OPT to require more memory, and it will take it longer
  259.     to search the larger array of command words.
  260.  
  261.  
  262.  
  263.        In utilizing an external data file, the programming was done "blind".
  264.     That is, P-OPT works by a set of rules rather than acting in response to
  265.     specific words.  This means that only if (when?) the PROCOMM script
  266.     language changes would you outgrow P-OPT. Also in using an external
  267.     text file, some added features are available and explained later.
  268.  
  269.  
  270.  
  271.      6.0  Advanced features
  272.  
  273.        Most of the best parts of P-OPT will never be seen by you.:
  274.  
  275.     Since there are some BBS out there that still require a semi colon top
  276.     stack commands, P-OPT will check to see if a line with a ";" in it is
  277.     inside a quote and if so, leave it alone.
  278.  
  279.     However, if an additional remark trails a quoted semi colon, it will be
  280.     stripped whether in a quote or not.
  281.  
  282.     In scooting quoted literals to the left (TRANSMIT "password" becoming
  283.     TRANS"password"), P-OPT looks to see that they is a space preceeding the
  284.     first quote, and if so, only then is it supposed to scoot it to the
  285.     left.
  286.  
  287.     P-OPT is not case sensitive, either in the original source file, or the
  288.     PROCOMM data command file.  P-OPT will convert the source line to upper
  289.     case, maul it to death, then output the result.  The output will NOT be
  290.     converted to upper case however.  The output will be the literal from
  291.     the source file AND from the PROCMDS.LST data file.  If you use lower
  292.     case in the data file, and some upper in the source file, P-OPT will (in
  293.     spite of you) make a match and replace it successfuilly, but the target
  294.     (output) file will be in mixed case.
  295.  
  296.  
  297.  
  298.     Most all of PROCOMM's command key words are the first command on a line,
  299.     the obvious exceptions of SET and IF.  In the interest of speed,  P-OPT
  300.     first looks for a meta-command, then strips blanks and then looks at
  301.     the first word for optimization.  If that word is "SET" or "IF" then it
  302.     shifts to the next word to optimize.  If the first is "IF" and the second
  303.     is "NOT" then it shifts to the third word.
  304.  
  305.  
  306.     In all cases nothing right of a quote is optimized, so that if you are
  307.     RGETing of FINDing something, it will look for what ever you have quoted.
  308.  
  309.  
  310.     Note: If you have a specific application that leaves unoptimized command
  311.     words in the optimized (output) line, I would like to know about it and
  312.     see an example or two, as this algorithm is not etched in stone, but
  313.     it is just about as quick as I can make it.
  314.  
  315.  
  316.  
  317.     6.1   Advanced meta-command usage
  318.  
  319.     When used with the printer as an output, whatever your source file has
  320.     assigned to $AUTHR:, $TITLE: and $SUBTL: as well as $VERSN: will be
  321.     printed at the top of each page along with a page number.
  322.  
  323.     As noted, meta-commands can be reassigned throughout the command file.
  324.     This means that for print formatting, aside from just inserting the
  325.     $PAGEF: meta-command to force a form feed, you could also PRIOR to the
  326.     form feed, reassign $SUBTL: meta-command to assign a separate subtitle
  327.     for each page holding a specfic routine.
  328.  
  329.       Irregardless of their placement in the source file, P-OPT should read
  330.     and act on all meta commands as encountered, as long as they start in
  331.     column one.  The reason for needing to declare them in the first 10
  332.     lines of the source for starters, is so that BEFORE P-OPT goes to output
  333.     the first few lines, it needs to know things like $LNCNT: and $PGSIZ:
  334.     and so forth.  To accomplish this, P-OPT "pre-reads" the first few (10)
  335.     lines to get these parameters, then it starts over to actually optimize
  336.     the file.
  337.  
  338.       After that, meta-command parameters can be changed on the fly to allow
  339.     you to go so far as to print easch routine on a separate page ($PAGEF:)
  340.     and even $SUBTL: each page with a different name.
  341.  
  342.     Finally, the new QMODEM 3.0 just came out, with a greatly enhanced
  343.     script language, and it appears that you could edit the PROCMDS.LST to
  344.     allow some possible translations from PROCOMM to QMODEM.  That is,
  345.     PROCOMM uses TRANSMIT to signal the system to send a literal or a string,
  346.     QMODEM uses SEND.  In your PROCMDS.LST you could edit a copy to read:
  347.     TRANSMIT,SEND
  348.  
  349.     Converting back from QMODEM to PROCOMM probably will not work because
  350.     most of QMODEM's words seem to be 4 chars long or less already. eg
  351.     SEND,TRANS
  352.     would not work because "SEND" would be ignored being under 5 chars long.
  353.     Additionally, aside from not knowing if QMODEM even recognizes
  354.     shorter versions of the key words, it looks like P-OPT's meta-commands
  355.     might choke Qmodem or vice versa since they both use the "$word" format.
  356.  
  357.  
  358.  
  359.     7.0   Future Releases
  360.  
  361.        One of the most powerful and features of P-OPT are it's meta-commands.
  362.     I toyed with one for printer codes, but they are too variable and it is
  363.     easier for you to set it into conpressed print, or whatever than me,
  364.     given the variety of printers.
  365.  
  366.        However, if you have a suggestion for additional meta-commands, call
  367.     my board and leave a note, and we will look into it.  I do plan a relase
  368.     soon with enhanced titling especially in the print mode, but as an
  369.     optimizer per se it seems to work very well.  I also think I can triomn a
  370.     few seconds here and there if I tried real hard.
  371.  
  372.  
  373.  
  374.  
  375.  
  376.     8.0  Acknowledgements
  377.  
  378.        QMDOEM is Copyright John Friel
  379.        PROCOMM is Copyright DATASTORM
  380.        VERSA is Copyright Allen Brunson
  381.  
  382.     P-OPT is Copyright InfoSoft, 1987,      ALL RIGHTS RESERVED
  383.  
  384.  
  385.     P-OPT is Copyrighted, but no "donations" or "contributions" are
  386.     solicited for it, nor is the source code available for sal
  387.  
  388.     P-OPT may not be sold, even for nominal (or otherwise) so-called disk
  389.     fee, nor may it be included in any library, collection.  It may not
  390.     be offered for a donation or for monetary remuneration of any sort
  391.     or included in a collection of programs by any organization either
  392.     for-profit or non-profit.  P-OPT must also be distributed with
  393.     this documention in uneditted form.
  394.  
  395.  
  396.        Special Thanks to Allen Brunson, without who's need for something to
  397.     optimize VERSA, P-OPT would never have been conceived.
  398.  
  399.        P-OPT is written in QuickBASIC 2.01
  400.        All routines used in P-OPT were written by me or are from my own
  401.     library of routines except for EXIST (to check if a file exists).
  402.  
  403.  
  404.     9.0  History
  405.  
  406.     April 28, 1987   - Released  Version 1.0
  407.  
  408.  
  409.  
  410.